package com.zahb.qadx.ui.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.zahb.qadx.R;
import com.zahb.qadx.model.MainFunc2;
import com.zahb.qadx.util.ImageLoaderKt;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;

/**
 * Created by Zdw on 2020/10/10 11:29
 */
public class BannerAdapter extends BaseBannerAdapter<MainFunc2, BannerAdapter.BannerViewHolder> {

    @Override
    protected void onBind(BannerViewHolder holder, MainFunc2 data, int position, int pageSize) {
        holder.bindData(data, position, pageSize);
    }

    @Override
    public BannerViewHolder createViewHolder(@NonNull ViewGroup parent, View itemView, int viewType) {
        return new BannerViewHolder(itemView);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_banner_view;
    }

    public static class BannerViewHolder extends BaseViewHolder<MainFunc2> {

        BannerViewHolder(@NonNull View itemView) {
            super(itemView);
        }

        @Override
        public void bindData(MainFunc2 data, int position, int pageSize) {
            ImageView imageView = findView(R.id.iv_banner);
            ImageLoaderKt.loadImageSameCorners(imageView, data.getIcon(), 20f);
        }
    }
}
